package com.baymax.datascope.enums;

import com.baymax.exception.GlobalException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 数据权限枚举
 *
 * @Author: baymax
 * @CreateTime: 2023/4/2 15:06
 * @Version: 1.0
 */
@Getter
@AllArgsConstructor
public enum DataScopeEnum {

    ALL(1, "全部"),
    CUSTOM(2, "自定义数据权限"),
    SELF(3, "仅本人")
    ;

    private final Integer dataScope;
    private final String description;

    public static DataScopeEnum findByDataScope(Integer dataScope) {
        for (DataScopeEnum dataScopeEnum : values()) {
            if (dataScopeEnum.dataScope.equals(dataScope)) {
                return dataScopeEnum;
            }
        }
        throw new GlobalException("未找到对应的数据权限");
    }
}
